<template>
  <van-list
    v-model="loading"
    :finished="finished"
    finished-text="没有更多了"
    @load="onLoad"
  >
    <van-cell class="article-item">
      <template #title>
        <div class="head" v-for="item in list" :key="item.id" @click="$router.push(`/detail/${item.id}`)">
          <div class="con">
            <p class="title van-ellipsis">{{ item.title }}</p>
            <div class="body van-multi-ellipsis--l2">{{ item.catename }}</div>
            <div class="foot">
              收藏 ({{item.lovenum }}) | 点赞 ({{
                item.click
              }})
            </div>
          </div>
          <div class="prc">
            <img :src="`http://124.223.14.236:8060/${item.pic}`" alt="" />
          </div>
        </div>
      </template>
    </van-cell>
  </van-list>
</template>

<script>
import { myClassifyApi } from '@/api/classify'
export default {
  name: 'MjClassify',
  props: ['id'],
  data () {
    return {
      loading: false,
      finished: false,
      page: 1,
      limit: 10,
      list: []
    }
  },
  methods: {
    async onLoad () {
      const { data } = await myClassifyApi({
        page: this.page,
        limit: this.limit,
        cateid: this.id
      })
      this.list = [...this.list, ...data.data.list.data]
      this.loading = false
      this.page++
      if (this.limit > data.data.list.count) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.article-item {
  .head {
    display: flex;
    .con {
      flex: 1;
      overflow: hidden;
      padding-left: 10px;
      p {
        margin: 0;
        line-height: 1.5;
        &.title {
          width: 280px;
        }
        &.other {
          font-size: 10px;
          color: #999;
        }
      }
    }
  }
  .body {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-top: 10px;
  }
  .foot {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
  }
  .prc {
    flex: 1;
    overflow: hidden;
    padding-left: 30px;
    img {
      width: 100px;
      height: 100px;
    }
  }
}
</style>
